﻿using System;
using Server.Items;
using System.Collections;
using System.Collections.Generic;
using Server.Commands;
using Server.Mobiles;
using Server.Targeting;
using Server.Network;
using Server.Spells;

namespace Server.Engines.CastSystem
{
    public class MagiaTest : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Magia Test", "FraseTest",
            212,
            9061,
            Reagent.Bloodmoss,
            Reagent.MandrakeRoot
        );

        public override double DefTempoDiRecitazione { get { return 3.0; } }
        public override int DefMana { get { return 10; } }
        public override bool DefRichiedeTarget { get { return true; } }
        public override int Livello { get { return 1; } }

        public MagiaTest(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCastTarget(Mobile mobile)
        {
            Caster.SendMessage("CAST!");

            DoFizzle();
        }
    }

    public class Luce : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Luce", "LUCE",
            0,
            0,
            Reagent.Bloodmoss
        );

        public override double DefTempoDiRecitazione { get { return 3.0; } }
        public override int DefMana { get { return 8; } }
        public override bool DefRichiedeTarget { get { return true; } }
        public override int DefMaxRange { get { return 14; } }
        public override int Livello { get { return 1; } }

        public Luce(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCastTarget(Mobile mobile)
        {
            Caster.Skills[SkillName.Swords].Base = 25.0;
        }
    }

    public class DardoIncantato : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Dardo Incantato", "DARDO",
            0,
            0,
            Reagent.BlackPearl
        );

        public override double DefTempoDiRecitazione { get { return 3.0; } }
        public override int DefMana { get { return 8; } }
        public override bool DefRichiedeTarget { get { return true; } }
        public override int DefMaxRange { get { return 14; } }
        public override int Livello { get { return 1; } }

        public DardoIncantato(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCastTarget(Mobile mobile)
        {
            // Da sito: (10 - 14) + (1 - 3)*Livello
            int rand1 = Utility.RandomMinMax(10, 14);
            int rand2 = Utility.RandomMinMax(1, 3);
            int bonusLivello = CastHelper.BonusDannoDaLivello(this);

            int danno = rand1 + rand2 * bonusLivello;

            Caster.SendMessage("rand1 {0} rand2 {1} bonusLivello {2} danno {3}", rand1, rand2, bonusLivello, danno);

            CastHelper.ApplicaDannoMagico(Caster, mobile, danno, DamageType.Energia, true);
 
            Caster.MovingParticles(mobile, 0x36E4, 5, 0, false, false, 3006, 0, 0);
            Caster.PlaySound(0x1E5);
        }
    }

    public class Astuzia : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Astuzia", "ASTUZIA",
            0,
            0,
            Reagent.Ginseng
        );

        public override double DefTempoDiRecitazione { get { return 3.0; } }
        public override int DefMana { get { return 8; } }
        public override bool DefRichiedeTarget { get { return true; } }
        public override int DefMaxRange { get { return 8; } }
        public override int Livello { get { return 1; } }

        public Astuzia(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCastTarget(Mobile mobile)
        {
            // 360 + Livello * 6
            TimeSpan durata = TimeSpan.FromSeconds(360 + Caster.Livello * 6);

            // 12 + Livello / 3
            int potenza = 12 + Caster.Livello / 3;

            CastSystem.RegisterCurseOrBless(mobile, this, durata, true);

            mobile.AddStatMod(new StatMod(StatType.Int, "Magia_Astuzia_Int", potenza, durata));

            mobile.FixedParticles( 0x375A, 10, 15, 5011, EffectLayer.Head );
		    mobile.PlaySound( 0x1EB );
        }
    }

    public class Debolezza : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Debolezza", "DEBOLEZZA",
            0,
            0,
            Reagent.Nightshade
        );

        public override double DefTempoDiRecitazione { get{ return 3.0; } }
        public override int DefMana { get { return 8; } }
        public override bool DefRichiedeTarget { get { return true; } }
        public override int DefMaxRange { get { return 10; } }
        public override int Livello { get { return 1; } }

        public Debolezza(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCastTarget(Mobile mobile)
        {
            // 120 + Livello * 5
            TimeSpan durata = TimeSpan.FromSeconds(360 + Caster.Livello * 6);
           
            CastSystem.RegisterCurseOrBless(mobile, this, durata, true);

            mobile.AddStatMod(new StatMod(StatType.Forza, "Magia_Debolezza_Forza", -4, durata));

            mobile.FixedParticles( 0x3779, 10, 15, 5009, EffectLayer.Waist );
			mobile.PlaySound( 0x1E6 );
        }
    }

    public class Scudo : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Scudo", "SCUDO",
            0,
            0,
            Reagent.Garlic
        );

        public override double DefTempoDiRecitazione { get { return 2.0; } }
        public override int DefMana { get { return 10; } }
        public override bool DefRichiedeTarget { get { return false; } }
        public override int Livello { get { return 1; } }

        public Scudo(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCast()
        {
            // 360 + Livello * 6
            TimeSpan durata = TimeSpan.FromSeconds(360 + Caster.Livello * 6);

            CastSystem.RegisterCurseOrBless(Caster, this, durata, true);

            Caster.AddStatMod(new StatMod(StatType.Difesa, "Magia_Scudo_Difesa", 14, durata));

            Caster.PlaySound( 0x1E9 );
		    Caster.FixedParticles( 0x375A, 9, 20, 5016, EffectLayer.Waist );
        }
    }

    public class EvocaMostri_1 : CastMagia
    {
        private static SpellInfo m_Info = new SpellInfo(
            "Evoca Mostri 1", "EVOCA1",
            0,
            0,
            Reagent.BlackPearl,
            Reagent.SpidersSilk
        );

        public override double DefTempoDiRecitazione { get { return 5.0; } }
        public override int DefMana { get { return 15; } }
        public override bool DefRichiedeTarget { get { return false; } }
        public override int Livello { get { return 1; } }

        public EvocaMostri_1(Mobile caster)
            : base(caster, m_Info)
        {
        }

        public override void OnCast()
        {
            // TODO
        }
    }
}
